package com.project.service.GoodsService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.GoodsBean;
import com.project.mapper.IGoodsMapper.IGoodsMapper;
import com.project.service.GoodsService.IGoodsService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
@Service
@Transactional
public class GoodsServicelmpl implements IGoodsService {
    @Autowired
    private IGoodsMapper mapper;
    @Override
    public void addGoods(GoodsBean goods) {
        mapper.addGoods(goods);
    }

    @Override
    public GoodsBean findById(int goodsId) {
        return mapper.findById(goodsId);
    }

    @Override
    public void updatePrice(int goodsId, int newPrice) {
        mapper.updatePrice(goodsId, newPrice);
    }


    @Override
    public PageInfo<GoodsBean> findByItem(int pageNO, String name, String type, Integer startNum, Integer endNum) {
        PageHelper.startPage(pageNO,PAGESIZE);
        PageInfo<GoodsBean> pageInfo = PageInfo.of(mapper.findByItem(name, type, startNum, endNum));
        return pageInfo;
    }

    @Override
    public void updateNumber(int goodsId, int newNum) {
        mapper.updateNumber(goodsId, newNum);
    }


}
